<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setAttribute("basePath", basePath);
%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="${basePath}/css/default/om-default.css" />
<link rel="stylesheet" href="${basePath}/css/base.css" />
<link rel="stylesheet" href="${basePath}/css/meroperation.css" />
<link rel="stylesheet" type="text/css" href="${basePath}/css/grid-extra.css" />
<script type="text/javascript" src="${basePath}/js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="${basePath}/js/operamasks-ui.min.js" charset="utf-8"></script>
<script type="text/javascript" src="${basePath}/js/om-grid.js" charset="utf-8"></script>
<script type="text/javascript" src="${basePath}/js/om-calendar.js" charset="utf-8"></script>
<script type="text/javascript" src="${basePath}/js/util.js"></script>
<script type="text/javascript" src="${basePath}/js/tools.js" charset="utf-8"></script>
<title>Insert title here</title>
<script type="text/javascript">
	
$(function(){
	
	$('#grid').omGrid({
				title:'',
				limit:20,
				dataSource:'${basePath}/privilege/role/queryRoles.do',
				height: gridHeight(),
				method:'POST',
				showIndex:false,
				autoFit:true,
				onSuccess:function(data,testStatus,XMLHttpRequest,event){
					if(undefined == data || undefined == data.total) {
						data.total = 0;
						data.rows = '';
						alert('读取数据出错，请再次刷新尝试。如多次尝试无效，请联系相关人员！');
					} else if (false == data.success) {
						alert(data.message);
						data.total = 0;
						data.rows = '';
					}
				
				},
				colModel:[
					{
					header:'角色描述',name:'description',width:80,align:'center'
					},
					{
						header:'角色描述',name:'description',width:80,align:'center'
					},
					{
					header:'状态',name:'available',width:80,align:'center',renderer:function(colValue, rowData, rowIndex){
							if(colValue =='1')
							{
								return "启用";
							}else{
								return "禁用";
							}
						}
					},{
					header:'创建人',name:'createPerson',width:80,align:'center'
					},{
					header:'创建时间',name:'createDate',width:80,align:'center'
					},{
					header:'操作',name:'createDate',width:80,align:'center',renderer:function(colValue, rowData, rowIndex){
							return "<a href=\"#\" onclick=\'authorize("+rowData.id+")\' >授权</a>";						
						}
					}
				]
			});

})

function info(rid)
{

}
function authorize(rid)
{
	window.location.href ="${basePath}/privilege/role/toRoleAuthorization.do?roleId="+rid;
}

function roleAdd()
{
	window.location.href ="${basePath}/privilege/role/toRoleAddPage.do";
}
</script>
</head>
<body>
		<div class='ui-nav fn-clear pl15'>
		    <div class='fn-left ft-14 pt5'><strong>权限管理    > 用户管理</strong></div>
		</div>
		<button type='button' class='iconrept btn ml3' onclick="roleAdd()" id="roleAddBtn"  style="margin-left: 80px">
				                            <span></span>创建角色
		</button>
		<div class='ui-box-container'>
			<table id='grid'></table>
		</div>
</body>
</html>